package nero.yncc.com.createart.activity;

import android.graphics.Bitmap;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.KeyEvent;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;



import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

import nero.yncc.com.createart.R;
import nero.yncc.com.createart.base.BaseActivity;

/**
 * Created by nero on 2017/5/27.
 */
@ContentView(R.layout.activity_webview)
public class ActivityWeb extends BaseActivity {
    @ViewInject(R.id.webview)
    WebView webView;

    @Override
    protected void initView() {
        setTitleBarTitle(getIntent().getStringExtra("title"));
        WebSettings settings = webView.getSettings();
        settings.setJavaScriptEnabled(true);
//        settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
        webView.loadUrl(getIntent().getStringExtra("url"));

        webView.setWebChromeClient(new WebChromeClient() {}
        );
        webView.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                super.onPageStarted(view, url, favicon);

            }

            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);

            }
        });


    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {

        if(webView.canGoBack()){
            webView.goBack();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {

    }

}
